export const ComparisonResults = {
    BIGGER: 'bigger',
    SMALLER: 'smaller',
    EQUAL: 'equal'
}

/**
 * 比较两个值的大小
 * @param {number} keyA 
 * @param {number} keyB 
 * @returns {string} 'bigger' | 'smaller' | 'equal'
 */
export const compare = (keyA, keyB) => {
    if (keyA > keyB) {
        return ComparisonResults.BIGGER
    }
    if (keyA < keyB) {
        return ComparisonResults.SMALLER
    }
    if (keyA === keyB) {
        return ComparisonResults.EQUAL
    }
}

/**
 * 交换数组中两个索引所对应的值
 * @param {array} array
 * @param {number} indexA
 * @param {number} indexB
 */
export const swap = (array, indexA, indexB) => {
    const temp = array[indexA]
    array[indexA] = array[indexB]
    array[indexB] = temp
}